package com.woniuxy.lab.woniu_lab_boss.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 17292
 */
@Component
@Slf4j
public class Demo {

    public static final String ROOT_TEMP_RANGE_01 = "~/temp/range01";
    public static final String ROOT_TEMP = "~/temp/ready";

    public void demo(){
        try {
            log.info("开始测试");
            ShellUtil shell = ShellUtil.getShell("192.168.120.10", "root", "root123");

            log.info("创建用户的文件夹");
            //创建用户的文件夹
            shell.mkdir(ROOT_TEMP_RANGE_01);

            log.info("将docker-compose.yml文件复制进用户文件夹");
            //将docker-compose.yaml文件复制进用户文件夹
            shell.cp(ROOT_TEMP +"/docker-compose.yml", ROOT_TEMP_RANGE_01);

//            log.info("创建mysqlinit文件夹");
//            //创建mysqlinit文件夹
//            shell.mkdir(ROOT_TEMP_RANGE_01 + "/mysqlinit");

            log.info("将sql文件复制进用户文件夹");
            //将sql文件复制进用户文件夹
            shell.cpr(ROOT_TEMP +"/mysqlinit", ROOT_TEMP_RANGE_01 + "/mysqlinit");


            log.info("将用户文件复制到web文件夹");
            //将用户文件复制到web文件夹
            shell.cpr(ROOT_TEMP +"/web", (ROOT_TEMP_RANGE_01 ));

            log.info("将dockerfile文件复制进用户文件夹");
            //将dockerfile文件复制进用户文件夹
            shell.cp(ROOT_TEMP +"/Dockerfile", (ROOT_TEMP_RANGE_01));

            log.info("运行docker-compose");

            //运行docker-compose
            shell.startCompose();
        } catch (Exception e) {
            log.error("测试失败:{}", e);
            e.printStackTrace();
        }
    }


}
